#ifndef FLASHBOX4LOGOCONTAINER_H_
#define FLASHBOX4LOGOCONTAINER_H_



#define ADD_TIMER
#define USE_ERRORMSG_DLG 1
#define TEST 0

#include <coecntrl.h>
#include <coecobs.h>
#include "Jpg2Bitmap.h"
#include "FbProgressBar.h"
#include "WebClientEngine.h"



#if USE_ERRORMSG_DLG
#include "FbShowErrorMsg.h"
#endif

#ifdef _CHARGE_ON_LOGO_
#ifdef _SMS_CHARGE_
#include "ETCharge.h"
#endif
#endif



class CFlashbox4LogoContainer : public CCoeControl,CActive,
		MCoeControlObserver,MWebClientObserver
#ifdef _CHARGE_ON_LOGO_
		,MChargeObserver
#endif		
{
public:
	~CFlashbox4LogoContainer ();
	CFlashbox4LogoContainer();
	/**
	 * EPOC default constructor.
	 * @param aRect Frame rectangle for container.
	 */
	void ConstructL (const TRect& aRect );

private:
	// Functions from base classes
	/**
	 * From CoeControl,SizeChanged.
	 */
	void SizeChanged ();

	/**
	 * From CoeControl,CountComponentControls.
	 */
	TInt CountComponentControls () const;

	/**
	 * From CCoeControl,ComponentControl.
	 */
	CCoeControl* ComponentControl (TInt aIndex ) const;

	/**
	 * From CCoeControl,Draw.
	 */
	void Draw (const TRect& aRect ) const;

	/**
	 * From MCoeControlObserver
	 * Acts upon changes in the hosted control's state. 
	 *
	 * @param	aControl	The control changing its state
	 * @param	aEventType	The type of control event 
	 */
	void HandleControlEventL (CCoeControl* aControl, TCoeEvent aEventType );

	/**
	 * from CActive
	 */
	void RunL ();
	void DoCancel();
	////////////////////MWebClientObserver接口函数//////////////
	/**
	 * WebClientEvent()
	 * Called when event occurs in CWebClientEngine.
	 * @param aEventDescription: A event in textual format, e.g.
	 *                           "Transaction Successful"
	 */
	void WebClientEvent (const TInt aEvent, TInt aSessionId,/*const TDesC& aEventDescription,*/
	TInt aCode = 0 );

	/**
	 * WebClientHeaderReceived()
	 * Called when HTTP header is received.
	 * @param aHeaderData: Header field name and value
	 */
	void WebClientHeaderReceived (const TDesC8& aHeaderFiled, const TDesC8& aHeaderVal, TInt aSessionId );

	/**
	 * WebClientBodyReceivedComplete()
	 * Called when a part of the HTTP body is received.
	 * @param aBodyData:  Part of the body data received. (e.g. part of
	 *                    the received HTML page)
	 */
	void WebClientBodyReceivedComplete (const TDesC8& aBodyData, TInt aSessionId );
	
	/**
	 * 
	 */
	void ClientBodyReceived (const TDesC8& aBodyData, TBool aIsLast );
	
private:
	
	//Add function 'InitializeControl()' for initializing the control's data
	void InitializeControl ();

#ifdef ADD_TIMER
	/**
	 * Add DrawCallback() function, control LogoView showing time!
	 * */
	static TInt DrawCallback (TAny* pInstance );

	void ExitLogo ();
#endif
	
	//Data
	CFbsBitmap* pLogoMainbmp;

#ifdef ADD_TIMER
	CPeriodic* iPeriodic;
	TInt32 i_Timer;
#endif
	
#if USE_ERRORMSG_DLG
	CFbShowErrorMsg* m_pErrorMsgDlg;
	void DrawErrorAndTerminateApp ();
#endif
	
public:
	CFbProgressBar* m_pProgressBar;

#ifdef _CHARGE_ON_LOGO_
	void IsCharged (TBool aCharged, TInt aSum, TInt aCurrentNum );
	CETCharge * m_pETCharge;
	HBufC8 *m_pSmsContentString;
#endif
	enum TInitState
	{
		EStateOnInitHttp = 0x100, //初始化Http
		EStateChargeInit,	//计费初始话
		EStateOnQueryXml,//获取sms指令
		EStateOnCharge,
		EStateOnGePhoneNumber,//获取手机号码（向服务器发短信）//发送短信
		EStateOnExit
	};

	RTimer m_Timer;
	TInt m_State;
	

};

#endif /*FLASHBOX4LOGOCONTAINER_H_*/
